﻿//------------------------------------------------------------
// GenericPool
// Copyright © 2025 Mao Yin Hang. All rights reserved.
//------------------------------------------------------------
namespace GenericPool
{
    public static class CollectionPool<T1, T2> where T1 : ICollection<T2>, new()
    {
        private static ObjectPool<T1> objectPool = new ObjectPool<T1>(null, (a) => a.Clear());
        public static T1 Acquire()
        {
            return objectPool.Get();
        }
        public static void Release(T1 t)
        {
            objectPool.Release(t);
        }
    }

    public static class CollectionPool<T1, T2, T3> where T1 : IDictionary<T2, T3>, new()
    {
        private static ObjectPool<T1> objectPool = new ObjectPool<T1>(null, (a) => a.Clear());
        public static T1 Acquire()
        {
            return objectPool.Get();
        }
        public static void Release(T1 t)
        {
            objectPool.Release(t);
        }
    }

}
